class User < ActiveRecord::Base
    # for login
    acts_as_authentic do |c|
      c.logged_in_timeout = 15.minutes # default is 10.minutes
    end


    # one user has many todos
    has_many :todos
    # validate email
    #validates_presence_of     :email
    #validates_uniqueness_of   :email
    #validates_format_of :email,
      #:with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i,
      #:message => 'email must be valid'
    # validate password
    #validates_length_of :password, :in => 6..100

    def active?
      active
    end

    def activate!
      self.active = true
      save
    end

  def deliver_activation_instructions!
    reset_perishable_token!
    Notifier.deliver_activation_instructions(self)
  end

  def deliver_activation_confirmation!
    reset_perishable_token!
    Notifier.deliver_activation_confirmation(self)
  end

end

